<div id="form"></div>
<script>
var frm=$("#form").ajajform({
	header: "{{!title}}",
	cssclass: "ajajform",
	layouttemplate: '<table border="0" width="1250" align="center"><tr><td class="af-peditcol1"></td><td class="af-peditcol2"></td></tr></table>',
	submit: {
		url: '{{action}}',
		value: "{{!!save}}",
		ajaj: true,
		params: {mode: "save",id: '{{fields.id}}',category_id: '{{item.category_id}}',ajaj: 1{{if has_parent}},parent_id: {{parent.id}}{{/if}}}
	}
});
var columns={{JSON:columns}};
for (var i=0;i<columns.length;i++) {
	frm.ajajform("insertWidget",'.af-peditcol1',null,columns[i]);
}
frm.ajajform("insertWidget",'.af-peditcol1',null,{type:"label",name:"date_cr",label:"Дата создания",width:400,value:{{JSON:item.date_cr}}});

{{foreach grp in param_groups}}
frm.ajajform("insertWidget",'.af-peditcol2',null,{type:"label",name:"param_group_{{grp.id}}",label:"",value: "<b>{{grp.name}}</b>", width: 200,html:true});
var f,g;
{{foreach param in grp.params}}
f=frm.ajajform("insertWidget",'.af-peditcol2',null,{type:"textedit",name:"param_{{param.id}}",label:"{{param.name}}",width:300,value:{{JSON:param.value}},autocomplete:{minLength:0,source:{{JSON:param.values}}}});
{{/foreach}}
{{/foreach}}
</script>
